package edu.buaa.act.travel.m.tpdl;

public class ActivityFactory {
	
	private static ActivityFactory factory;
	
	private ActivityFactory(){
		
	}
	
	public static ActivityFactory getInstance(){
		if(factory == null){
			synchronized (ActivityFactory.class) {
				if(factory == null){
					factory = new ActivityFactory();
				}
			}
		}
		return factory;
	}
	
	public Activity create(String type) {
		if (FlightActivity.TYPE.equals(type)) {
			return new FlightActivity();
		} else if (HotelActivity.TYPE.equals(type)) {
			return new HotelActivity();
		} else if (ResortActivity.TYPE.equals(type)) {
			return new ResortActivity();
		} else if (RestaurantActivity.TYPE.equals(type)) {
			return new RestaurantActivity();
		} else if (TrainActivity.TYPE.equals(type)) {
			return new TrainActivity();
		} else if (TrafficActivity.TYPE.equals(type)) {
			return new TrafficActivity();
		} else if (CityActivity.TYPE.equals(type)) {
			return new CityActivity();
		} else {
			System.out.println("unexcepted type :" + type);
			return null;
		}
	}
}
